package com.wtcrazy.service.Impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wtcrazy.dao.ProductClassMapper;
import com.wtcrazy.dao.ProductMapper;
import com.wtcrazy.entity.Product;
import com.wtcrazy.service.IProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.UUID;

@Service
public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> implements IProductService {
    @Autowired
    private ProductMapper productMapper;
    @Autowired
    private ProductClassMapper productClassMapper;

    @Override
    public Boolean saveProduct(Product product) {
        if (product.getId() == null) {
            product.setId(UUID.randomUUID().toString().replace("-", ""));
            return save(product);
        } else {
            return updateById(product);
        }
    }

    @Override
    public String deleteProduct(String id) {
        productMapper.deleteProduct(id);
        return "删除成功";
    }


}
